package cn.apienvrypt.context;

import java.util.Objects;

/**
 * @author lfj
 */
public class HandleContext implements AutoCloseable {

	private static ThreadLocal<String> ctx = new ThreadLocal<>();

	public static void setValue(String value) {
		ctx.set(value);
	}

	public static String currentValue() {
		return ctx.get();
	}

	public static void remove() {
		if(Objects.nonNull(ctx)) {
			ctx.remove();
		}
	}

	@Override
	public void close() {
		ctx.remove();
	}
}